import { defineStore } from 'pinia'
import  { type categoryL1List, getCtaegory1, getcateList, type categoryGroupList, type bannerList5, } from '@/api/category'

 export interface CategoryStoreStateData {
  categoryL1List: categoryL1List[],
  categoryId: 0,
  bannerList1:bannerList5[],
  categoryGroupList:categoryGroupList[],
  ImageList:bannerList5[],
  getItemList:[] 
 
}
export const useCategoryStore = defineStore('category', {
  state(): CategoryStoreStateData {
    return {
      categoryL1List: [],
      categoryId: 0,
      bannerList1:[],
      categoryGroupList:[],
      ImageList:[],
      getItemList:[],
     
    }
  },
  actions: {
    async getCategoryL1List() {
      try {
        const res = await getCtaegory1() 
        console.log(res)
        this.categoryL1List = res.data.categoryL1List

      } catch (error) {
        alert('错误')
      }
    },
    async getPagingListdData(id:number){
      try {
         const res = await getcateList(id)
         
         this.categoryGroupList = res.data.categoryGroupList as [] || []
         
         this.ImageList = res.data.currentCategory.bannerList as [] || []

        //  console.log(res)//
      } catch (error) {
          // console.log('9999')
          return Promise.reject(error)
      }
   },
  
 
  },
  getters: {}
})
